? config.php ? dbpatch.txt ? newpatch.txt ? patch-extra.txt ? patch.txt ? blog/backuplib.php ? lib/db/.install.xml.swp ? mod/assignment/type/blog Index: admin/settings/security.php =================================================================== RCS file: /cvsroot/moodle/moodle/admin/settings/security.php,v retrieving revision 1.29 diff -u -a -w -b -B -r1.29 security.php --- admin/settings/security.php 22 Jul 2008 04:07:59 -0000 1.29 +++ admin/settings/security.php 13 Aug 2008 04:16:14 -0000 @@ -46,6 +46,7 @@ 1 => get_string('personalblogs','blog'), 0 => get_string('disableblogs','blog')))); $temp->add(new admin_setting_configcheckbox('usetags', get_string('usetags','admin'),get_string('configusetags', 'admin'),'1')); + $temp->add(new admin_setting_configcheckbox('useassoc', get_string('useassoc','admin'),get_string('configuseassoc', 'admin'),'1')); $temp->add(new admin_setting_configcheckbox('keeptagnamecase', get_string('keeptagnamecase','admin'),get_string('configkeeptagnamecase', 'admin'),'1')); $temp->add(new admin_setting_configcheckbox('cronclionly', get_string('cronclionly', 'admin'), get_string('configcronclionly', 'admin'), 0)); $temp->add(new admin_setting_configpasswordunmask('cronremotepassword', get_string('cronremotepassword', 'admin'), get_string('configcronremotepassword', 'admin'), '')); Index: blocks/blog_menu/block_blog_menu.php =================================================================== RCS file: /cvsroot/moodle/moodle/blocks/blog_menu/block_blog_menu.php,v retrieving revision 1.18 diff -u -a -w -b -B -r1.18 block_blog_menu.php --- blocks/blog_menu/block_blog_menu.php 2 May 2008 04:37:04 -0000 1.18 +++ blocks/blog_menu/block_blog_menu.php 13 Aug 2008 04:16:15 -0000 @@ -1,6 +1,7 @@ dirroot .'/blog/lib.php'); +require_once($CFG->dirroot .'/course/lib.php'); class block_blog_menu extends block_base { @@ -11,7 +12,7 @@ } function get_content() { - global $CFG, $USER, $COURSE; + global $CFG, $USER, $COURSE, $DB, $PAGE; if (empty($CFG->bloglevel)) { $this->content->text = ''; @@ -39,22 +40,54 @@ $this->content = new stdClass; $this->content->footer = ''; - if (empty($this->instance) /*|| empty($CFG->blog_version)*/) { + if (empty($this->instance)) { // Either we're being asked for content without // an associated instance of the Blog module has never been installed. $this->content->text = $output; return $this->content; } - //if ( blog_isLoggedIn() && !isguest() ) { - $courseviewlink = ''; + //discover context for pre-loaded associations + $basefilters = array(); + if(!empty($COURSE)) $courseid = $COURSE->id; + switch($PAGE->get_type()) { + case PAGE_COURSE_VIEW: + $courseid = $PAGE->courserecord->id; + $basefilters['courseid'] = $courseid; + break; + case PAGE_BLOG_VIEW: + $basefilters = $PAGE->filters; + if(!empty($PAGE->filters['course'])) + $courseid = $PAGE->filters['course']; + if(!empty($PAGE->filters['mod'])) + $modid = $PAGE->filters['mod']; + if(!empty($PAGE->filters['user'])) + $userid = $PAGE->filters['user']; + if(!empty($PAGE->filters['group'])) + $groupid = $PAGE->filters['group']; + if(!empty($PAGE->filters['tag'])) + $tagid = $PAGE->filters['tag']; + break; + } + $addentrylink = ''; - $coursearg = ''; + $blogprefslink = ''; + $myviewlink = ''; + $siteviewlink = ''; + $courseviewlink = ''; + $modviewlink = ''; + $groupviewlink = ''; + $userviewlink = ''; + $tagviewlink = ''; + $coursepopuplink = ''; + $modpopuplink = ''; + $grouppopuplink = ''; + $userspopuplink = ''; + //create basic blog preference links + $coursearg = ''; $sitecontext = get_context_instance(CONTEXT_SYSTEM); - - if ($COURSE->id != SITEID) { - + if ($courseid != SITEID) { $incoursecontext = true; $curcontext = get_context_instance(CONTEXT_COURSE, $COURSE->id); } else { @@ -61,23 +94,13 @@ $incoursecontext = false; $curcontext = $sitecontext; } - $canviewblogs = has_capability('moodle/blog:view', $curcontext); - - /// Accessibility: markup as a list. - if ( (isloggedin() && !isguest()) && $incoursecontext && $CFG->bloglevel >= BLOG_COURSE_LEVEL && $canviewblogs) { - - $coursearg = '&courseid='.$COURSE->id; - // a course is specified - - $courseviewlink = '
';
print_user_picture($user, SITEID, $user->picture);
@@ -205,6 +221,14 @@
case 'draft':
$blogtype = get_string('publishtonoone', 'blog');
break;
+ case 'course':
+ $blogtype = !empty($CFG->useassoc) ? get_string('publishtocourseassoc', 'blog')
+ : get_string('publishtocourse', 'blog');
+ break;
+ case 'group':
+ $blogtype = !empty($CFG->useassoc) ? get_string('publishtogroupassoc', 'blog')
+ : get_string('publishtogroup', 'blog');
+ break;
case 'site':
$blogtype = get_string('publishtosite', 'blog');
break;
@@ -234,13 +258,52 @@
echo '';
}
+ //add associations
+ if ( !empty($CFG->useassoc) && $blog_associations = $DB->get_records('blog_association', array('blogid' => $blogEntry->id))) {
+ echo ' ';
+ $assoc_str = '';
+ foreach($blog_associations as $assoc_rec) { //first find and show the associated course
+ $context_rec = $DB->get_record('context', array('id' => $assoc_rec->contextid));
+ if($context_rec->contextlevel == CONTEXT_COURSE) {
+ $assoc_str .= '';
+ $assoc_str .= ' ';
+ }
+
+ if($unassociatedpost) {
+ echo '![]() ![]() '.get_string('associationunviewable', 'blog').' ';
+ }
+
/// Commands
echo '';
if (blog_user_can_edit_post($blogEntry)) {
echo ''.$stredit.'';
- echo '| '.$strdelete.' | ';
+ if(!$DB->record_exists_sql('SELECT a.timedue, a.preventlate, a.emailteachers, a.var2, asub.grade
+ FROM {assignment} a, {assignment_submissions} as asub WHERE
+ a.id = asub.assignment AND userid = '.$USER->id.' AND a.assignmenttype = \'blog\'
+ AND asub.data1 = \''.$blogEntry->id.'\''))
+ echo '| '.$strdelete.'';
+ echo ' | ';
}
echo ''.get_string('permalink', 'blog').'';
@@ -338,7 +401,17 @@
$options = array ( 'draft' => get_string('publishtonoone', 'blog') );
}
- if ($CFG->bloglevel > BLOG_USER_LEVEL) {
+ if ($CFG->bloglevel >= BLOG_GROUP_LEVEL) {
+ $options['group'] = empty($CFG->useassoc) ? get_string('publishtogroupassoc', 'blog')
+ : get_string('publishtogroup', 'blog');
+ }
+
+ if ($CFG->bloglevel >= BLOG_COURSE_LEVEL) {
+ $options['course'] = !empty($CFG->useassoc) ? get_string('publishtocourseassoc', 'blog')
+ : get_string('publishtocourse', 'blog');
+ }
+
+ if ($CFG->bloglevel >= BLOG_SITE_LEVEL) {
$options['site'] = get_string('publishtosite', 'blog');
}
@@ -462,30 +535,16 @@
/**
- * Main filter function.
+ * Generates an SQL query for retrieving blog entries
*/
- function blog_fetch_entries($postid='', $fetchlimit=10, $fetchstart='', $filtertype='', $filterselect='', $tagid='', $tag ='', $sort='lastmodified DESC', $limit=true) {
+ function blog_fetch_entries_sql($fetchlimit=10, $fetchstart='', $filters=array(), $sort='lastmodified DESC', $limit=true) {
global $CFG, $USER, $DB;
- /// the post table will be used for other things too
- $typesql = "AND p.module = 'blog'";
-
- /// set the tag id for searching
- if ($tagid) {
- $tag = $tagid;
- } else if ($tag) {
- if ($tagrec = $DB->get_record_sql("SELECT * FROM {tag} WHERE name LIKE ?", array($tag))) {
- $tag = $tagrec->id;
- } else {
- $tag = -1; //no records found
- }
- }
-
- // If we have specified an ID
+ // If we have specified a post ID
// Just return 1 entry
- if ($postid) {
- if ($post = $DB->get_record('post', array('id'=>$postid))) {
+ if (!empty($filters['post'])) {
+ if ($post = $DB->get_record('post', array('id'=>$filters['post']))) {
if (blog_user_can_view_user_post($post->userid, $post)) {
@@ -505,96 +564,148 @@
}
}
- $params = array();
+ // The query used to locate blog entries is complicated. It will be built from the following components:
+ $requiredfields = "p.*, u.firstname,u.lastname,u.email"; // the SELECT clause
+ $tables = array('p' => 'post', 'u' => 'user'); // components of the FROM clause (table_id => table_name)
+ $conditions = array('u.deleted = 0', 'p.userid = u.id', 'p.module = \'blog\''); // components of the WHERE clause (conjunction)
- if ($tag) {
- $tagtablesql = ", {tag_instance} ti";
- $tagquerysql = "AND ti.itemid = p.id AND ti.tagid = :tag AND ti.itemtype = 'post'";
- $params['tag'] = $tag;
- } else {
- $tagtablesql = '';
- $tagquerysql = '';
+ if (!empty($filters['tag'])) {
+ $tables['ti'] = 'tag_instance';
+ $conditions[] = 'ti.itemid = p.id';
+ $conditions[] = 'ti.tagid = '.$filters['tag'];
+ $conditions[] = 'ti.itemtype = \'post\'';
}
- if (isloggedin() && !has_capability('moodle/legacy:guest', get_context_instance(CONTEXT_SYSTEM), $USER->id, false)) {
- $permissionsql = "AND (p.publishstate = 'site' OR p.publishstate = 'public' OR p.userid = :userid)";
- $params['userid'] = $USER->id;
- } else {
- $permissionsql = "AND p.publishstate = 'public'";
- }
+
+ // build up a clause for permission constraints
// fix for MDL-9165, use with readuserblogs capability in a user context can read that user's private blogs
// admins can see all blogs regardless of publish states, as described on the help page
if (has_capability('moodle/user:readuserblogs', get_context_instance(CONTEXT_SYSTEM))) {
- $permissionsql = '';
- } else if ($filtertype=='user' && has_capability('moodle/user:readuserblogs', get_context_instance(CONTEXT_USER, $filterselect))) {
- $permissionsql = '';
- }
- /****************************************
- * depending on the type, there are 4 *
- * different possible sqls *
- ****************************************/
+ // don't add permission constraints
+ } else if(!empty($filters['user']) &&
+ has_capability('moodle/user:readuserblogs',
+ get_context_instance(CONTEXT_USER, (empty($filters['user']) ? 0 : $filters['user'])))) {
+ // don't add permission constraints
+ } else {
- $requiredfields = "p.*, u.firstname,u.lastname,u.email";
- if ($filtertype == 'course' && $filterselect == SITEID) { // Really a site
- $filtertype = 'site';
+
+ if (isloggedin() && !has_capability('moodle/legacy:guest', get_context_instance(CONTEXT_SYSTEM, SITEID), $USER->id, false)) {
+ $usergroups = '';
+ $usercourses = '';
+ $assocexists = $DB->record_exists('blog_association', array()); //dont check association records if there aren't any
+
+ foreach($DB->get_records('groups_members', array('userid' => $USER->id)) as $rec) {
+ $usergroups .= ($usergroups ? ', ' : '') . $rec->groupid;
+ }
+ foreach(get_my_courses($USER->id) as $course) {
+ $usercourses .= ($usercourses ? ', ' : '') . $course->context->id;
}
- switch ($filtertype) {
- case 'site':
+ if(!empty($filter['course'])) { //optimization to make searches faster
+ $filtercontext = get_context_instance(CONTEXT_COURSE, $filter['course']);
+ if(!in_array($filtercontext->id, $usercourses)) return array();
+ if(!empty($filter['group'])) {
+ if(!in_array($filters['group'], $usergroups)) return array();
+ }
+ }
- $SQL = "SELECT $requiredfields
- FROM {post} p, {user} u $tagtablesql
- WHERE p.userid = u.id $tagquerysql
- AND u.deleted = 0
- $permissionsql $typesql";
- break;
+ $permissionsql = '(p.userid = '.$USER->id.' ';
- case 'course':
- // all users with a role assigned
- $context = get_context_instance(CONTEXT_COURSE, $filterselect);
+ if($CFG->bloglevel >= BLOG_SITE_LEVEL) { // add permission to view site-level posts
+ $permissionsql .= ' OR p.publishstate = \'site\' ';
+ }
- // MDL-10037, hidden users' blogs should not appear
- if (has_capability('moodle/role:viewhiddenassigns', $context)) {
- $hiddensql = '';
+ if($CFG->bloglevel >= BLOG_GLOBAL_LEVEL) {
+ $permissionsql .= ' OR p.publishstate = \'public\' ';
+ }
+
+ if(empty($CFG->useassoc)) { // insure viewer shares *any* course/group with the poster
+ if($usergroups and $CFG->bloglevel >= BLOG_GROUP_LEVEL) {
+ $tables['gm'] = 'groups_members';
+ $permissionsql .= ' OR (p.publishstate = \'group\' '.
+ ' AND gm.userid = p.userid AND gm.groupid IN ('.$usergroups.'))';
+ }
+ if($usercourses and $CFG->bloglevel >= BLOG_COURSE_LEVEL) {
+ $tables['ra'] = 'role_assignments';
+ $permissionsql .= ' OR (p.publishstate = \'course\' '.
+ ' AND p.userid = ra.userid AND ra.contextid IN ('.$usercourses.'))';
+ }
+ } else if($assocexists) { // insure viewer has access to the associated course (if course or group level access is used)
+ if($usercourses and $CFG->bloglevel >= BLOG_COURSE_LEVEL) {
+ $tables['ba'] = 'blog_association';
+ $permissionsql .=' OR (p.publishstate = \'course\' AND p.id = ba.blogid AND ba.contextid IN ('.$usercourses.'))';
+ }
+ if($usergroups and $CFG->bloglevel >= BLOG_GROUP_LEVEL) {
+ $tables['gma'] = 'groups_members';
+ $tables['gmb'] = 'groups_members';
+ $tables['ba'] = 'blog_association';
+ $permissionsql .= ' OR (p.publishstate = \'group\' AND p.id = ba.blogid AND ba.contextid IN ('.$usercourses.')
+ AND gma.groupid = gmb.groupid AND gma.userid = '.$USER->id.' AND gmb.userid = p.userid) ';
+ }
+ }
+ $permissionsql .= ') ';
} else {
- $hiddensql = 'AND ra.hidden = 0';
+ $permissionsql = "p.publishstate = 'site'";
+ }
+ $conditions[] = $permissionsql; //add permission constraints
}
- $SQL = "SELECT $requiredfields
- FROM {post} p, {user} u, {role_assignments} ra $tagtablesql
- WHERE p.userid = ra.userid $tagquerysql
- AND ra.contextid ".get_related_contexts_string($context)."
- AND u.id = p.userid
- AND u.deleted = 0
- $hiddensql $permissionsql $typesql";
+ if (!empty($filters['course'])) {
+ if($filters['course'] == SITEID) { // Really a site
+ $filters['site'] = true;
+ unset($filters['course']);
+ }
+ }
- break;
+ $specificsql = '';
+ if(!empty($filters['site'])) { //view posts for the whole site
+ //no constraints to add in this case
+ }
- case 'group':
+ if(!empty($filters['mod'])) { //only view posts associated with a particular mod
+ $context = get_context_instance(CONTEXT_MODULE, $filters['mod']);
+ $tables['ba'] = 'blog_association';
+ $conditions[] = 'p.id = ba.blogid';
+ $conditions[] = 'ba.contextid = '.$context->id;
+ }
- $SQL = "SELECT $requiredfields
- FROM {post} p, {user} u, {groups_members} gm $tagtablesql
- WHERE p.userid = gm.userid AND u.id = p.userid $tagquerysql
- AND gm.groupid = :groupid
- AND u.deleted = 0
- $permissionsql $typesql";
- $params['groupid'] = $filterselect;
- break;
-
- case 'user':
-
- $SQL = "SELECT $requiredfields
- FROM {post} p, {user} u $tagtablesql
- WHERE p.userid = u.id $tagquerysql
- AND u.id = :uid
- AND u.deleted = 0
- $permissionsql $typesql";
- $params['uid'] = $filterselect;
- break;
+ if(!empty($filters['course'])) { // view posts for all members of a course
+ $tables['ra'] = 'role_assignments';
+ $context = get_context_instance(CONTEXT_COURSE, $filters['course']);
+
+ // MDL-10037, hidden users' blogs should not appear
+ if (!has_capability('moodle/role:viewhiddenassigns', $context)) {
+ $conditions[] = 'ra.hidden = 0';
+ }
+
+ $conditions[] = 'p.userid = ra.userid';
+ $conditions[] = 'ra.contextid '.get_related_contexts_string($context);
+ if(!empty($CFG->useassoc) && empty($filters['mod'])) { // only show blog entries associated with this course
+ $tables['ba'] = 'blog_association';
+ $conditions[] = 'p.id = ba.blogid';
+ $conditions[] = 'ba.contextid = '.$context->id;
+ }
+ }
+
+ if(!empty($filters['group'])) { // view posts for all members of a group
+ $tables['gm'] = 'groups_members';
+ $conditions[] = 'p.userid = gm.userid';
+ $conditions[] = 'gm.groupid = '.$filters['group'];
+ if(!empty($CFG->useassoc)) { // only show blog entries associated with this course
+ $tables['ba'] = 'blog_association';
+ $course_context = get_context_instance(CONTEXT_COURSE, $DB->get_field('groups', 'courseid', array('id' => $filters['group'])));
+ $conditions[] = 'gm.groupid = '.$filters['group'];
+ $conditions[] = 'ba.contextid = '.$course_context->id;
+ $conditions[] = 'ba.blogid = p.id';
+ }
+ }
+
+ if(!empty($filters['user'])) { // view posts for a single user
+ $conditions[] = 'u.id = '.$filters['user'];
}
$limitfrom = 0;
@@ -605,75 +716,63 @@
$limitnum = $fetchlimit;
}
- $orderby = "ORDER BY $sort";
-
- $records = $DB->get_records_sql("$SQL $orderby", $params, $limitfrom, $limitnum);
-
- if (empty($records)) {
- return array();
+ $tablessql = ''; // build up the FROM clause
+ foreach($tables as $tablename => $table) {
+ $tablessql .= ($tablessql ? ', ' : '').'{'.$table.'} '.$tablename;
}
- return $records;
+ $conditionssql = ''; // build up the WHERE clause
+ foreach($conditions as $condition) {
+ $conditionssql .= ($conditionssql ? ' AND ' : '').$condition;
}
+ return 'SELECT '.$requiredfields.' FROM '.$tablessql.' WHERE '.$conditionssql.' GROUP BY p.id ORDER BY '. $sort;
+ }
/**
- * get the count of viewable entries, easiest way is to count blog_fetch_entries
- * this is used for print_paging_bar
- * this is not ideal, but because of the UNION in the sql in blog_fetch_entries,
- * it is hard to use $DB->count_records_sql
+ * Main filter function
*/
- function get_viewable_entry_count($postid='', $fetchlimit=10,
- $fetchstart='', $filtertype='', $filterselect='', $tagid='',
- $tag ='', $sort='lastmodified DESC') {
-
- $blogEntries = blog_fetch_entries($postid, $fetchlimit,
- $fetchstart, $filtertype, $filterselect, $tagid, $tag,
- $sort='lastmodified DESC', false);
+ function blog_fetch_entries($fetchlimit=10, $fetchstart='', $filters=array(), $sort='lastmodified DESC', $limit=true) {
+ global $DB;
+ $limitfrom = 0;
+ $limitnum = 0;
- return count($blogEntries);
+ if ($fetchstart !== '' && $limit) {
+ $limitfrom = $fetchstart;
+ $limitnum = $fetchlimit;
}
+ $SQL = blog_fetch_entries_sql($fetchlimit, $fetchstart, $filters, $sort, $limit);
+ $records = $DB->get_records_sql($SQL, array(), $limitfrom, $limitnum);
+ if (empty($records)) {
+ return array();
+ }
- /// Find the base url from $_GET variables, for print_paging_bar
- function get_baseurl($filtertype, $filterselect) {
-
- $getcopy = $_GET;
+ return $records;
+ }
- unset($getcopy['blogpage']);
+ function blog_get_viewable_entry_count($filters=array()) {
+ global $DB;
+ $SQL = blog_fetch_entries_sql(1,0,$filters,'lastmodified DESC',false);
- $strippedurl = strip_querystring(qualified_me());
- if(!empty($getcopy)) {
- $first = false;
- $querystring = '';
- foreach($getcopy as $var => $val) {
- if(!$first) {
- $first = true;
- if ($var != 'filterselect' && $var != 'filtertype') {
- $querystring .= '?'.$var.'='.$val;
- $hasparam = true;
- } else {
- $querystring .= '?';
- }
- } else {
- if ($var != 'filterselect' && $var != 'filtertype') {
- $querystring .= '&'.$var.'='.$val;
- $hasparam = true;
- }
- }
- }
- if (isset($hasparam)) {
- $querystring .= '&';
- } else {
- $querystring = '?';
- }
- } else {
- $querystring = '?';
+ //cut out the select statement and the group by and order by statements:
+ $chunks = split('(FROM)|(GROUP)', $SQL); //the middle chunk (id: 1) is the one we want
+ //the following groups all rows together, since all 'module' values will be 'blog'
+ $SQL = 'SELECT COUNT(*) FROM ' . $chunks[1] . ' GROUP BY module';
+ return $DB->count_records_sql($SQL);
}
- return strip_querystring(qualified_me()) . $querystring. 'filtertype='.
- $filtertype.'&filterselect='.$filterselect.'&';
+ function blog_get_blogs_url($filters) {
+ global $CFG;
+ return $CFG->wwwroot.'/blog/index.php?'.
+ (empty($filters['course']) ? '' : 'courseid='.$filters['course'].'&').
+ (empty($filters['mod']) ? '' : 'modid='.$filters['mod'].'&').
+ (empty($filters['group']) ? '' : 'groupid='.$filters['group'].'&').
+ (empty($filters['user']) ? '' : 'userid='.$filters['user'].'&').
+ (empty($filters['post']) ? '' : 'postid='.$filters['post'].'&').
+ (empty($filters['tag']) ? '' : 'tagid='.$filters['tag'].'&').
+ (empty($filters['tagtext']) ? '' : 'tag='.$filters['tagtext']);
}
/**
@@ -687,4 +786,39 @@
FROM {post}
WHERE module = 'blog' AND courseid = 0");
}
+
+
+ /**
+ * add a single association for a blog entry
+ * @param int blogid - id of blog post
+ */
+ function blog_add_association($blogid, $contextid, $allow_add_course = true) {
+ global $DB;
+
+ $assoc_object = new StdClass;
+ $assoc_object->contextid = $contextid;
+ $assoc_object->blogid = $blogid;
+ $DB->insert_record('blog_association', $assoc_object);
+ }
+
+ /**
+ * remove all associations for a blog post
+ * @param int blogid - id of the blog post
+ */
+ function blog_remove_associations_for_post($blogid) {
+ global $DB;
+ $DB->delete_records('blog_association', array('blogid' => $blogid));
+ }
+
+ /**
+ * remove all associations for the blog posts of a particular user
+ * @param int userid - id of user whose blog associations will be deleted
+ */
+ function blog_remove_associations_for_user($userid) {
+ global $DB;
+ foreach(blog_fetch_entries(0,0,array('user' => $userid), 'lasmodified DESC', false) as $post) {
+ blog_remove_associations_for_post($post->id);
+ }
+ }
+
?>
Index: course/lib.php
===================================================================
RCS file: /cvsroot/moodle/moodle/course/lib.php,v
retrieving revision 1.612
diff -u -a -w -b -B -r1.612 lib.php
--- course/lib.php 8 Aug 2008 05:25:54 -0000 1.612
+++ course/lib.php 13 Aug 2008 04:16:18 -0000
@@ -2355,6 +2355,7 @@
function delete_course_module($id) {
global $CFG, $DB;
require_once($CFG->libdir.'/gradelib.php');
+ require_once($CFG->dirroot.'/blog/lib.php');
if (!$cm = $DB->get_record('course_modules', array('id'=>$id))) {
return true;
@@ -2374,7 +2375,9 @@
}
}
- return $DB->delete_records('course_modules', array('id'=>$cm->id));
+ $context = get_context_instance(CONTEXT_MODULE, $id);
+ return $DB->delete_records('course_modules', array('id'=>$cm->id)) &&
+ $DB->delete_records('blog_association', array('contextid'=>$context->id));
}
function delete_mod_from_section($mod, $section) {
Index: lang/en_utf8/admin.php
===================================================================
RCS file: /cvsroot/moodle/moodle/lang/en_utf8/admin.php,v
retrieving revision 1.218
diff -u -a -w -b -B -r1.218 admin.php
--- lang/en_utf8/admin.php 7 Aug 2008 22:56:34 -0000 1.218
+++ lang/en_utf8/admin.php 13 Aug 2008 04:16:19 -0000
@@ -781,6 +781,8 @@
$string['webproxyinfo'] = 'Fill in following options if your Moodle server can not access internet directly. Internet access is required for download of environment data, language packs, RSS feeds, timezones, etc. PHP cURL extension is highly recommended.'; $string['xmlrpcrecommended'] = 'Installing the optional xmlrpc extension is useful for Moodle Networking functionality.'; $string['xmlstrictheaders'] = 'XML strict headers'; +$string['useassoc'] = 'Enable associations'; +$string['configuseassoc'] = 'Should users be able to organize their blog by associating entries with courses and course modules?'; $string['ziprequired'] = 'The Zip PHP extension is now required by Moodle, info-ZIP binaries or PclZip library are not used anymore.'; ?> Index: lang/en_utf8/assignment.php =================================================================== RCS file: /cvsroot/moodle/moodle/lang/en_utf8/assignment.php,v retrieving revision 1.27 diff -u -a -w -b -B -r1.27 assignment.php --- lang/en_utf8/assignment.php 22 May 2008 07:24:35 -0000 1.27 +++ lang/en_utf8/assignment.php 13 Aug 2008 04:16:19 -0000 @@ -131,6 +131,7 @@ $string['typeonline'] = 'Online text'; $string['typeupload'] = 'Advanced uploading of files'; $string['typeuploadsingle'] = 'Upload a single file'; +$string['typeblog'] = 'Blog post'; $string['unfinalize'] = 'Revert to draft'; $string['unfinalizeerror'] = 'An error occurred and that submission could not be reverted to draft'; $string['uploadbadname'] = 'This filename contained strange characters and couldn\'t be uploaded'; @@ -145,5 +146,5 @@ $string['viewfeedback'] = 'View assignment grades and feedback'; $string['viewsubmissions'] = 'View $a submitted assignments'; $string['yoursubmission'] = 'Your submission'; - +$string['maxpublishstate'] = 'Maximum visibility for blog entry before duedate'; ?> Index: lang/en_utf8/blog.php =================================================================== RCS file: /cvsroot/moodle/moodle/lang/en_utf8/blog.php,v retrieving revision 1.26 diff -u -a -w -b -B -r1.26 blog.php --- lang/en_utf8/blog.php 24 Jul 2008 04:59:29 -0000 1.26 +++ lang/en_utf8/blog.php 13 Aug 2008 04:16:19 -0000 @@ -67,5 +67,18 @@ $string['viewsiteentries'] = 'View site entries'; $string['wrongpostid'] = 'Wrong blog post id'; $string['worldblogs'] = 'The world can read entries set to be world-accessible'; - +$string['associations'] = 'Associations';$string['publishtocourse'] = 'Users sharing a course with you'; +$string['publishtogroup'] = 'Users sharing a group with you'; +$string['publishtocourseassoc'] = 'Members of the associated course'; +$string['publishtogroupassoc'] = 'Your group members in the associated course'; +$string['associationunviewable'] = 'This entry cannot be viewed by others until a course is associated with it or the \'Publish To\' field is changed'; +$string['mustassociatecourse'] = 'If you are publishing to course or group members, you must associate a course with this entry'; +$string['viewuserentries'] = 'View user entries'; +$string['viewmodentries'] = 'View module entries'; +$string['viewgroupentries'] = 'View group entries'; +$string['viewcourseblogs'] = 'View entries for course...'; +$string['viewmodblogs'] = 'View entries for module...'; +$string['viewgroupblogs'] = 'View entries for group...'; +$string['viewblogsfor'] = 'View all entries for...'; +$string['filterblogsby'] = 'Filter entries by...'; ?> Index: lib/accesslib.php =================================================================== RCS file: /cvsroot/moodle/moodle/lib/accesslib.php,v retrieving revision 1.509 diff -u -a -w -b -B -r1.509 accesslib.php --- lib/accesslib.php 6 Aug 2008 05:07:47 -0000 1.509 +++ lib/accesslib.php 13 Aug 2008 04:16:21 -0000 @@ -2099,7 +2099,8 @@ if ($context = $DB->get_record('context', array('contextlevel'=>$contextlevel, 'instanceid'=>$instanceid))) { $result = $DB->delete_records('role_assignments', array('contextid'=>$context->id)) && $DB->delete_records('role_capabilities', array('contextid'=>$context->id)) && - $DB->delete_records('context', array('id'=>$context->id)); + $DB->delete_records('context', array('id'=>$context->id)) && + $DB->delete_records('blog_association', array('contextid'=>$context->id)); // do not mark dirty contexts if parents unknown if (!is_null($context->path) and $context->depth > 0) { @@ -2779,6 +2780,7 @@ function role_unassign($roleid=0, $userid=0, $groupid=0, $contextid=0, $enrol=NULL) { global $USER, $CFG, $DB; + require_once($CFG->dirroot.'/group/lib.php'); $success = true; Index: lib/db/install.xml =================================================================== RCS file: /cvsroot/moodle/moodle/lib/db/install.xml,v retrieving revision 1.164 diff -u -a -w -b -B -r1.164 install.xml --- lib/db/install.xml 7 Aug 2008 10:17:47 -0000 1.164 +++ lib/db/install.xml 13 Aug 2008 04:16:21 -0000 @@ -4,7 +4,21 @@ xsi:noNamespaceSchemaLocation="../../lib/xmldb/xmldb.xsd" > |